﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WQDSkin.Forms.Component
{
    public class WQDEditPageHeaderBar : Control
    {
        private BasePage basePage = null;

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            Button btnLeft = (Button)this.Template.FindName("btnGoBack", this);
            btnLeft.Click += BtnLeft_Click; ;

            DependencyObject parent = LogicalTreeHelper.GetParent(this);
            DependencyObject parent2 = LogicalTreeHelper.GetParent(parent);
            if (parent2 is BasePage)
            {
                this.basePage = (BasePage)parent2;
            }
        }

        private void BtnLeft_Click(object sender, RoutedEventArgs e)
        {
            if (basePage != null)
            {
                basePage.Cancel();
            }

        }
         
        public string Title
        {
            get { return (string)GetValue(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Title.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty TitleProperty =
            DependencyProperty.Register("Title", typeof(string), typeof(WQDEditPageHeaderBar), 
                new PropertyMetadata("主题"));


    }
}
